<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增专家组管理')"/>
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-group-add">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专家组名称：</label>
                <div class="col-sm-8">
                    <input name="groupName" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">排序：</label>
                <div class="col-sm-8">
                    <input name="sortOrder" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专家：</label>
                <div class="col-sm-8">
                    <select id="post" class="form-control select2-multiple" multiple required>
                        <option th:each="post:${posts}" th:value="${post.userId}" th:text="${post.userName}"></option>
                    </select>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/group"
    $("#form-group-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-group-add").serializeArray();
            var expertList = $.form.selectSelects("post");
            data.push({"name": "expertList", "value": expertList});
            $.operate.save(prefix + "/add", data);
        }
    }

    $(function() {
        $('#post').select2({
            placeholder: "请选择专家",
            allowClear: true
        });
    })
</script>
</body>
</html>